#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int chen(int b, int n)
{
	if (n == 1)
		return b;
	if (n == 2)
		return b * 16;
	else
		return  chen(b, n - 1) * 16;
}
	int main()
{
	int a,n=0,b,c;
	int sum=0;
	for (c = 10;c; c++)
	{
		a = c;
		n = 0;
		sum = 0;
		while (a)
		{
			b = a % 10;
			a = a / 10;
			n++;
			sum += chen(b, n);
		}
		if (sum % c == 0)
			break;
	}
	printf("%d", c);
	return 0;
}